<template>
  <div class="trace_wrapper">
    <el-collapse accordion>
      <el-collapse-item accordion v-for="(item, index) in regs" :key="index" 
      v-clipboard:copy="item.regNo" v-clipboard:success="onCopy" v-clipboard:error="onCopyError">
        <template slot="title">
          <i class="header-icon el-icon-info"></i>&nbsp;&nbsp;&nbsp;
          <span class="title_text">挂号单 &nbsp;&nbsp;&nbsp; KB-{{item.regNo.substring(0,6)}} &nbsp;&nbsp;&nbsp; {{item.time}}</span><span>&nbsp;&nbsp;&nbsp;{{item.traceList.length}}</span>  
        </template>
        <TraceItems :traceList="item.traceList"></TraceItems>
      </el-collapse-item>
    </el-collapse>
  </div>
</template>

<script>
import TraceItems from '../components/TraceItems';
import { myGet } from "../utils/api";

export default {
  data(){
    return {
      regs: []
    }//data return end
  }, //data end
  mounted(){
    myGet('/reg/all', null).then(res => {
      console.debug(res.data.res)
      var myres = res.data.res
      this.regs = myres
    }).catch(err => {

    })
  },
  methods:{
    onCopyError(){
      this.$message({showClose: true, message: '复制失败', type: 'error'})
    },
    onCopy(e){
      // this.$message({showClose: true, message: '复制成功', type: 'success'})
    },
  },
  components: {
    TraceItems
  }

}
</script>

<style scoped>
.trace_wrapper{
  padding: 40px;
}
.title_text{
  color: rgb(175, 166, 154);
}
</style>